package com.nsu.tly.service;

import com.nsu.tly.dao.UserMapper;
import com.nsu.tly.entity.User;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description:
 * @Author: Elder Tang
 * @Date: 2021/7/17 16:48
 */
@Service
public class UserServiceImpl implements UserService{


    @Autowired
    private UserMapper userMapper;

    @Override
    public User findUserById(Integer id) {
        return  userMapper.selectByPrimaryKey(id);
    }

    @Override
    public Boolean loginCheck(String uname, String upass) {
        User user=new User();
        user.setUserName(uname);
        user.setPassWord(upass);
        User u=userMapper.selectByNameAndPass(user);
        if(u!=null){
            return true;
        }else {
            return false;
        }
    }

    @Override
    //@Transactional
    public List<User> selectAll() {
        return userMapper.selectAll();
    }
}
